package edu.scau.mis.cloth.service.impl;

import edu.scau.mis.cloth.entity.GsPayment;
import edu.scau.mis.cloth.dao.GsPaymentDao;
import edu.scau.mis.cloth.service.GsPaymentService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (GsPayment)表服务实现类
 *
 * @author makejava
 * @since 2022-04-18 10:22:21
 */
@Service("gsPaymentService")
public class GsPaymentServiceImpl implements GsPaymentService {
    @Resource
    private GsPaymentDao gsPaymentDao;


    @Override
    public int queryById(Integer id) {
        return gsPaymentDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param gsPayment 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<GsPayment> queryByPage(GsPayment gsPayment, PageRequest pageRequest) {
        long total = this.gsPaymentDao.count(gsPayment);
        return new PageImpl<>(this.gsPaymentDao.queryAllByLimit(gsPayment, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param
     * @return 实例对象
     */
    @Override
    public int insert(Integer orderTotalrealpayment,String payWay,String orderId){
        return this.gsPaymentDao.insert(orderTotalrealpayment,payWay,orderId);
    }

    @Override
    public GsPayment update(GsPayment gsPayment) {
        return null;
    }



    @Override
    public boolean deleteById(String orderId) {
        return this.gsPaymentDao.deleteById(orderId) > 0;
    }
}
